package com.luguokong.pet_rescue.mapper;

import com.luguokong.pet_rescue.pojo.Order;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    public int insertOrder(Order order);
    public int deleteOrderById(int order_id);
    public int updateOrderById(Order order);
    public List<Order> selectOrderAllByUserId(int user_id);
    public Order selectOrderById(int order_id);
    public List<Order> selectOrderAll();
    public List<Order> selectOrderAllByDateByDesc();

    @Select("select * from orders limit #{pageNum},#{pageSize}")
    public List<Order> selectOrderAllByPageNumByPageSize(int pageNum, int pageSize);

    @Select("select count(*) from orders")
    public int selectDataCount();

//    查询每个宠物类型的订单数量
    @Select("SELECT pet_type, count(order_id) as counts from pet_food " +
            "INNER JOIN orders " +
            "ON pet_food.food_id = orders.food_id " +
            "GROUP BY pet_type")
    public List<Map<String, Number>> selectGroupByPetType();
}
